import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.LinkedList;
import java.util.List;

import org.codehaus.groovy.tools.shell.commands.SaveCommand;

import controllers.Tasks;
import play.*;
import play.jobs.*;
import play.test.*;
import models.*;

@OnApplicationStart
public class Bootstrap extends Job {

	public void doJob() {
		initData();
	}

	public static void initData() {

		if (User.count() == 0) {
			EventType et1 = new EventType("Meeting").save();
			EventType et2 = new EventType("Sprint").save();
			EventType et3 = new EventType("Customized Meeting").save();
			EventType et4 = new EventType("Default").save();
			EventType et5 = new EventType("Sprint Review").save();
			EventType et6 = new EventType("Component Meeting").save();
			EventType et7 = new EventType("blabla").save();

			TaskType t1 = new TaskType("Bug", true).save();
			TaskType t2 = new TaskType("Impediment", true).save();
			TaskType t3 = new TaskType("Feature", true).save();
			TaskType t4 = new TaskType("Coding", false).save();
			TaskType t5 = new TaskType("Documentation", true).save();
			TaskType t6 = new TaskType("Implementation", true).save();

			TaskStatus st1 = new TaskStatus("NEW", true).save();
			TaskStatus st2 = new TaskStatus("FIXED", true).save();
			TaskStatus st3 = new TaskStatus("RESOLVED", true).save();
			TaskStatus st4 = new TaskStatus("CLOSED", true).save();
			TaskStatus st5 = new TaskStatus("STARTED", true).save();

			Action action1 = new Action("Create System Role", "").save();// Admin
			Action action2 = new Action("Edit System Role", "").save(); // Admin
			Action action3 = new Action("Delete System Role", "").save();// Admin
			Action action4 = new Action("Create Project Role", "").save(); // Project
			// Admin
			Action action5 = new Action("Edit Project Role", "").save(); // Project
			// Admin
			Action action6 = new Action("Delete Project Role", "").save();// Project
			// Admin
			Action action7 = new Action("Invite guests to my project", "")
					.save();// project Admin
			Action action8 = new Action("Request role in project", "").save();// registered
			// user
			Action action9 = new Action(
					"Grant/reject a Project Member role-request", "").save();//
			Action action10 = new Action("Invite Users to the project", "")
					.save();
			Action action11 = new Action(
					"Edit the permissions of new/built-in roles in my project",
					"").save();
			Action action12 = new Action(
					"Request to be deleted from a project", "").save();
			Action action13 = new Action(
					"Approve or reject a deletion request of a Registered User",
					"").save();
			Action action14 = new Action(
					"Approve or reject deletion request of a Project Member",
					"").save();

			Action action15 = new Action("create a project", "").save(); // registered
			// user,developer,scrum
			// master,projectAdmin,system
			// admin
			Action action16 = new Action("Edit my project", "").save(); // Project
			// Admin,
			// system
			// admin
			Action action17 = new Action("Delete my project", "").save(); // Project
			// Admin
			Action action18 = new Action(
					"Specify number of sprints in a project", "").save();// Scrum
			// master
			Action action19 = new Action("Create a sprint in a project", "")
					.save();// Scrum master
			Action action20 = new Action("Edit the start date of an event", "")
					.save();// Scrum master
			Action action21 = new Action("Edit the end date of an event", "")
					.save();// Scrum master
			Action action22 = new Action("Remove a sprint from a project", "")
					.save();// Scrum master
			Action action23 = new Action("accept and reject Meeting request",
					"").save();// scrum master, projectAdmin
			Action action24 = new Action("associate developer to event", "")
					.save();// scrum master, project Admin
			Action action25 = new Action("associate tasks to event", "").save();// Scrum
			// master,
			// project
			// admin
			Action action26 = new Action("associate stories to event", "")
					.save(); // Scrum master,project Admin

			Action action27 = new Action(
					"Create/edit/delete demo entry for a userstory in my component",
					"").save();// developer
			Action action28 = new Action(
					"Create/edit/Delete User story in my project", "").save();// developer
			Action action29 = new Action(
					"Create/edit/delete Task in my project", "").save();// developer
			Action action30 = new Action("View all user stories in my project",
					"").save();// developer
			Action action31 = new Action(
					"Create/edit/delete application roles in my project ", "")
					.save(); // scrum master
			Action action32 = new Action(
					"Associate/disassociate application roles to/from a user story",
					"").save();// developer
			Action action33 = new Action(
					"Suggest that a developer be assigned to a task", "")
					.save();// developer
			Action action34 = new Action("Set/edit priority of a task",
					"Done through creating/editing the task").save();// developer
			Action action35 = new Action("Set/edit dependances between tasks",
					"Done through creating/editing the task").save();// developer
			Action action36 = new Action(
					"Associate a task to a specific sprint in my project", "")
					.save();// developer
			Action action37 = new Action(
					"Associate stories to a specific sprint in my project", "")
					.save();// developer
			Action action38 = new Action(
					"Edit dependances between user stories", "").save();// developer
			Action action39 = new Action("review a task", "").save(); // project
			// member
			Action action40 = new Action("associate a task to a user story", "")
					.save();// developer
			Action action41 = new Action(
					"set total effort estimation of a task", "").save();// developer
			Action action42 = new Action(
					"Create/Edit/delete task type in my project", "").save();// scrum
			// master
			Action action43 = new Action(
					"Create/Edit/Delete task status in my project", "").save();// scrum
			// master
			Action action44 = new Action("assign a developer to a task", "")
					.save(); // scrum master
			Action action45 = new Action(
					"approve requests by developers to be reviewers", "")
					.save(); // scrum master
			Action action46 = new Action(
					"edit/set the priority of a user story in my project", "")
					.save();// product owner
			Action action47 = new Action("can be assigned to a task", "")
					.save(); // Developer
			Action action48 = new Action("approve task type review requests",
					"").save(); // Scrum Master

			Action action49 = new Action("Edit the project backlog priority",
					" ").save();// Product Owner
			Action action50 = new Action("Edit the project backlog story", " ")
					.save();// Product Owner, developer,scrum master, project
			// Admin
			Action action51 = new Action("Edit the project backlog notes", " ")
					.save();// Product Owner, developer, scrum master, project
			// Admin
			Action action52 = new Action("View the sprint component backlog",
					"").save();// Developer/product owner/scrum master/ project
			// admin
			Action action53 = new Action(
					"View notes associated with a review meeting", "").save();// Scrum
			// master
			Action action54 = new Action(
					"Edit the project backlog Failure & success demo", " ")
					.save();// Product Owner, developer, scrum master, project
			// admin,
			Action action55 = new Action(" edit the assignee of a task ", "")
					.save(); // scrum master
			Action action56 = new Action("Edit the project backlog depends on",
					" ").save();// Product Owner,scrum master, project Admin
			Action action57 = new Action(
					"Estimate effort for every daily task", "").save();// Developer
			Action action58 = new Action("View the project backlog", "").save();// All
			// except
			// project
			// member/registered
			// user
			Action action59 = new Action("View the sprint backlog", "").save();// Developer/product
			// owner,
			// project
			// admin,
			// scrum
			// master
			Action action60 = new Action("View reports and statistics", "")
					.save();// All except project member/registered user
			Action action61 = new Action("View Burn Down Chart", "").save();
			Action action62 = new Action("View the impediment log", "").save();
			Action action63 = new Action("Set type of a task to be impediment",
					"").save();// Developer
			Action action64 = new Action("Become assigned to impediment tasks",
					"").save();// Scrum master

			Action action65 = new Action("View Project Virtual Board", "")
					.save();
			Action action66 = new Action("View Meeting Snapshots", "").save();
			Action action67 = new Action("View Component Virtual Board", "")
					.save();
			Action action68 = new Action("View previous snapshots", "").save();
			Action action69 = new Action(
					"Mark myself as attendant in some meeting", "").save();
			Action action70 = new Action(
					"Change Columns' positions in a board", "").save();
			Action action71 = new Action(
					"Add/ rename/ delete/ hide and show columns", "").save();
			Action action72 = new Action("hide and show userstories", "")
					.save();
			Action action73 = new Action("hide and show tasks", "").save();
			Action action74 = new Action("Drag and Drop Tasks", "").save();
			Action action75 = new Action("Edit Task", "").save();
			Action action76 = new Action("Edit Story", "").save();

			Action action77 = new Action(
					"Request to be deleted from the system", "").save();
			Action action78 = new Action("associate note to event", "").save();
			Action action79 = new Action(
					"Request to change my role in project", "").save();
			Action action80 = new Action(
					"Edit project default sprint duration", "").save();
			Action action81 = new Action("Respond to project creation requset",
					"").save();
			Action action82 = new Action("dev Edit the project backlog proint",
					" ").save();// developer
			Action action83 = new Action("Delete an event", " ").save();
			Action action84 = new Action("dev Edit the project backlog story",
					" ").save();// developer
			Action action85 = new Action("dev Edit the project backlog notes",
					" ").save();// developer
			Action action86 = new Action(
					"dev Edit the project backlog Failure & success demo", " ")
					.save();// developer
			Action action87 = new Action("assign myself as a reviewer", " ")
					.save();// developer
			Action action88 = new Action("Master Board", "").save();
			Action action89 = new Action("Create a Component", "").save();
			Action action90 = new Action("Associate a meeting to a sprint", "")
					.save();
			Action action91 = new Action("Request a meeting", "").save();
			Action action92 = new Action("Set effort estimation metric", "")
					.save();

			Role sysAdmin = new Role("System Admin", true).save();
			Role projectAdmin = new Role("Project Admin", true).save();
			Role developer = new Role("Developer", true).save();
			Role scrumMaster = new Role("Scrum Master", true).save();
			Role projectMember = new Role("Project Member", true).save();
			Role registeredUser = new Role("Registered User", true).save();
			Role productOwner = new Role("Product Owner", true).save();

			sysAdmin.actions.add(action1);
			sysAdmin.actions.add(action2);
			sysAdmin.actions.add(action3);
			sysAdmin.actions.add(action4);
			sysAdmin.actions.add(action5);
			sysAdmin.actions.add(action6);
			sysAdmin.actions.add(action7);
			sysAdmin.actions.add(action8);
			sysAdmin.actions.add(action9);
			sysAdmin.actions.add(action10);
			sysAdmin.actions.add(action11);
			sysAdmin.actions.add(action12);
			sysAdmin.actions.add(action13);
			sysAdmin.actions.add(action14);
			sysAdmin.actions.add(action15);
			sysAdmin.actions.add(action16);
			sysAdmin.actions.add(action17);
			sysAdmin.actions.add(action18);
			sysAdmin.actions.add(action19);
			sysAdmin.actions.add(action20);
			sysAdmin.actions.add(action21);
			sysAdmin.actions.add(action22);
			sysAdmin.actions.add(action23);
			sysAdmin.actions.add(action24);
			sysAdmin.actions.add(action25);
			sysAdmin.actions.add(action26);
			sysAdmin.actions.add(action27);
			sysAdmin.actions.add(action28);
			sysAdmin.actions.add(action29);
			sysAdmin.actions.add(action30);
			sysAdmin.actions.add(action31);
			sysAdmin.actions.add(action32);
			sysAdmin.actions.add(action33);
			sysAdmin.actions.add(action34);
			sysAdmin.actions.add(action35);
			sysAdmin.actions.add(action36);
			sysAdmin.actions.add(action37);
			sysAdmin.actions.add(action38);
			sysAdmin.actions.add(action39);
			sysAdmin.actions.add(action40);
			sysAdmin.actions.add(action41);
			sysAdmin.actions.add(action42);
			sysAdmin.actions.add(action43);
			sysAdmin.actions.add(action44);
			sysAdmin.actions.add(action45);
			sysAdmin.actions.add(action46);
			sysAdmin.actions.add(action47);
			sysAdmin.actions.add(action48);
			sysAdmin.actions.add(action49);
			sysAdmin.actions.add(action50);
			sysAdmin.actions.add(action51);
			sysAdmin.actions.add(action52);
			sysAdmin.actions.add(action53);
			sysAdmin.actions.add(action54);
			sysAdmin.actions.add(action55);
			sysAdmin.actions.add(action56);
			sysAdmin.actions.add(action57);
			sysAdmin.actions.add(action58);
			sysAdmin.actions.add(action59);
			sysAdmin.actions.add(action60);
			sysAdmin.actions.add(action61);
			sysAdmin.actions.add(action62);
			sysAdmin.actions.add(action63);
			sysAdmin.actions.add(action64);
			sysAdmin.actions.add(action65);
			sysAdmin.actions.add(action66);
			sysAdmin.actions.add(action67);
			sysAdmin.actions.add(action68);
			sysAdmin.actions.add(action69);
			sysAdmin.actions.add(action70);
			sysAdmin.actions.add(action71);
			sysAdmin.actions.add(action72);
			sysAdmin.actions.add(action73);
			sysAdmin.actions.add(action74);
			sysAdmin.actions.add(action75);
			sysAdmin.actions.add(action76);
			sysAdmin.actions.add(action77);
			sysAdmin.actions.add(action78);
			sysAdmin.actions.add(action79);
			sysAdmin.actions.add(action80);
			sysAdmin.actions.add(action81);
			sysAdmin.actions.add(action82);
			sysAdmin.actions.add(action83);
			sysAdmin.actions.add(action87);
			sysAdmin.actions.add(action88);
			sysAdmin.actions.add(action89);
			sysAdmin.actions.add(action90);
			sysAdmin.actions.add(action91);
			sysAdmin.actions.add(action92);

			projectAdmin.actions.add(action4);
			projectAdmin.actions.add(action5);
			projectAdmin.actions.add(action6);
			projectAdmin.actions.add(action7);
			projectAdmin.actions.add(action9);
			projectAdmin.actions.add(action10);
			projectAdmin.actions.add(action11);
			projectAdmin.actions.add(action14);
			projectAdmin.actions.add(action15);
			projectAdmin.actions.add(action16);
			projectAdmin.actions.add(action17);
			projectAdmin.actions.add(action22);
			projectAdmin.actions.add(action23);
			projectAdmin.actions.add(action24);
			projectAdmin.actions.add(action25);
			projectAdmin.actions.add(action26);
			projectAdmin.actions.add(action29);
			projectAdmin.actions.add(action31);
			projectAdmin.actions.add(action50);
			projectAdmin.actions.add(action51);
			projectAdmin.actions.add(action52);
			projectAdmin.actions.add(action54);
			projectAdmin.actions.add(action56);
			projectAdmin.actions.add(action58);
			projectAdmin.actions.add(action59);
			projectAdmin.actions.add(action60);
			projectAdmin.actions.add(action61);
			projectAdmin.actions.add(action65);
			projectAdmin.actions.add(action66);
			projectAdmin.actions.add(action67);
			projectAdmin.actions.add(action68);
			projectAdmin.actions.add(action70);
			projectAdmin.actions.add(action71);
			projectAdmin.actions.add(action73);
			projectAdmin.actions.add(action74);
			projectAdmin.actions.add(action75);
			projectAdmin.actions.add(action77);
			projectAdmin.actions.add(action78);
			projectAdmin.actions.add(action80);
			projectAdmin.actions.add(action83);
			projectAdmin.actions.add(action87);
			projectAdmin.actions.add(action88);
			projectAdmin.actions.add(action89);
			projectAdmin.actions.add(action90);
			projectAdmin.actions.add(action92);

			developer.actions.add(action15);
			developer.actions.add(action25);
			developer.actions.add(action27);
			developer.actions.add(action28);
			developer.actions.add(action29);
			developer.actions.add(action30);
			developer.actions.add(action31);
			developer.actions.add(action32);
			developer.actions.add(action33);
			developer.actions.add(action34);
			developer.actions.add(action35);
			developer.actions.add(action36);
			developer.actions.add(action37);
			developer.actions.add(action38);
			developer.actions.add(action39);
			developer.actions.add(action40);
			developer.actions.add(action41);
			developer.actions.add(action45);
			developer.actions.add(action47);
			developer.actions.add(action52);
			developer.actions.add(action57);
			developer.actions.add(action58);
			developer.actions.add(action59);
			developer.actions.add(action60);
			developer.actions.add(action61);
			developer.actions.add(action63);
			developer.actions.add(action65);
			developer.actions.add(action66);
			developer.actions.add(action67);
			developer.actions.add(action68);
			developer.actions.add(action69);
			developer.actions.add(action70);
			developer.actions.add(action71);
			developer.actions.add(action72);
			developer.actions.add(action73);
			developer.actions.add(action74);
			developer.actions.add(action75);
			developer.actions.add(action76);
			developer.actions.add(action77);
			developer.actions.add(action79);
			developer.actions.add(action82);
			developer.actions.add(action84);
			developer.actions.add(action85);
			developer.actions.add(action86);
			developer.actions.add(action91);

			scrumMaster.actions.add(action15);
			scrumMaster.actions.add(action18);
			scrumMaster.actions.add(action19);
			scrumMaster.actions.add(action20);
			scrumMaster.actions.add(action21);
			scrumMaster.actions.add(action22);
			scrumMaster.actions.add(action23);
			scrumMaster.actions.add(action24);
			scrumMaster.actions.add(action25);
			scrumMaster.actions.add(action26);
			scrumMaster.actions.add(action29);
			scrumMaster.actions.add(action31);
			scrumMaster.actions.add(action42);
			scrumMaster.actions.add(action43);
			scrumMaster.actions.add(action44);
			scrumMaster.actions.add(action45);
			scrumMaster.actions.add(action48);
			scrumMaster.actions.add(action50);
			scrumMaster.actions.add(action51);
			scrumMaster.actions.add(action52);
			scrumMaster.actions.add(action53);
			scrumMaster.actions.add(action54);
			scrumMaster.actions.add(action55);
			scrumMaster.actions.add(action56);
			scrumMaster.actions.add(action58);
			scrumMaster.actions.add(action59);
			scrumMaster.actions.add(action60);
			scrumMaster.actions.add(action61);
			scrumMaster.actions.add(action62);
			scrumMaster.actions.add(action64);
			scrumMaster.actions.add(action65);
			scrumMaster.actions.add(action66);
			scrumMaster.actions.add(action67);
			scrumMaster.actions.add(action68);
			scrumMaster.actions.add(action69);
			scrumMaster.actions.add(action70);
			scrumMaster.actions.add(action71);
			scrumMaster.actions.add(action72);
			scrumMaster.actions.add(action73);
			scrumMaster.actions.add(action74);
			scrumMaster.actions.add(action75);
			scrumMaster.actions.add(action76);
			scrumMaster.actions.add(action77);
			scrumMaster.actions.add(action78);
			scrumMaster.actions.add(action79);
			scrumMaster.actions.add(action80);
			scrumMaster.actions.add(action83);
			scrumMaster.actions.add(action87);
			scrumMaster.actions.add(action88);
			scrumMaster.actions.add(action89);
			scrumMaster.actions.add(action90);
			scrumMaster.actions.add(action92);

			projectMember.actions.add(action15);
			projectMember.actions.add(action8);
			projectMember.actions.add(action12);
			projectMember.actions.add(action16);
			projectMember.actions.add(action39);
			projectMember.actions.add(action77);
			projectMember.actions.add(action79);

			productOwner.actions.add(action15);
			productOwner.actions.add(action31);
			productOwner.actions.add(action46);
			productOwner.actions.add(action49);
			productOwner.actions.add(action50);
			productOwner.actions.add(action51);
			productOwner.actions.add(action52);
			productOwner.actions.add(action54);
			productOwner.actions.add(action56);
			productOwner.actions.add(action58);
			productOwner.actions.add(action59);
			productOwner.actions.add(action60);
			productOwner.actions.add(action61);
			productOwner.actions.add(action65);
			productOwner.actions.add(action66);
			productOwner.actions.add(action67);
			productOwner.actions.add(action68);
			productOwner.actions.add(action76);
			productOwner.actions.add(action77);
			productOwner.actions.add(action79);

			registeredUser.actions.add(action15);
			registeredUser.actions.add(action77);

			productOwner.save();
			sysAdmin.save();
			registeredUser.save();
			developer.save();
			projectAdmin.save();
			scrumMaster.save();
			projectMember.save();

			User salem = new User("Salem", "sayed", "Abdel Gawad",
					"salemsayed", "12345678", "salemsayed@gmail.com",
					"0101420501", "Mohandeseen", "Cairo", "Egypt", "").save();
			User rana = new User("Rana", "Ashraf", "Morsy", "r257",
					"password1", "r257@hotmail.com", "0123456788", "Nasr City",
					"Cairo", "Eqypt", "").save();
			User hafiza = new User("Sayed", "Sayed", "Abou Hafiza", "hafiza",
					"password1", "hafiza@hotmail.com", "0123456788", "Haram",
					"Cairo", "Eqypt", "").save();
			User rawan = new User("Rawan", "Tarek", "Khalil", "rawan.khalil",
					"password2", "rawan@hotmail.com", "0124967141", "Katameya",
					"Cairo", "Egypt", "").save();
			User nemo = new User("nemo", "clown", "fish", "finding.nemo",
					"password2", "mohamed.nagy90@gmail.com", "0123423521",
					"coral reef", "Hurghada", "Egypt", "1").save();
			User projMember = new User("Frank.", "Creepy", "Frankenstein",
					"frank.stein", "0123456245", "frankenstein@gmail.com",
					"0123456245", "attic", "Virginia", "USA", "").save();
			User ramy = new User("Ramy", "Wafa", "Wafa", "ramy.wafa",
					"12345678", "ramy.wafa2@gmail.com", "012342352", "Haram",
					"Giza", "Egypt", "").save();
			User fatma = new User("Fatma", "El Sayed", "Meawad", "fatma.m",
					"12345678", "fatma.m@gmail1.com", "0123423532", "Maadi",
					"Cairo", "Egypt", "").save();

			new UserRoleProject(true, salem, sysAdmin, null).save();

			EffortUnit hours = new EffortUnit(true, "Hours").save();
			EffortUnit points = new EffortUnit(true, "Points").save();

			Calendar cal1 = new GregorianCalendar();
			cal1.set(2010, Calendar.APRIL, 01);
			Calendar cal2 = new GregorianCalendar();
			cal2.set(2010, Calendar.APRIL, 28);
			Calendar cal3 = new GregorianCalendar();
			cal3.set(2010, Calendar.APRIL, 01);
			Calendar cal4 = new GregorianCalendar();
			cal4.set(2010, Calendar.APRIL, 02);
			Calendar cal5 = new GregorianCalendar();
			cal5.set(2010, Calendar.MAY, 20);
			Calendar cal6 = new GregorianCalendar();
			cal6.set(2010, Calendar.MAY, 20);
			Calendar cal7 = new GregorianCalendar().getInstance();
			Calendar cal8 = new GregorianCalendar().getInstance();
			cal8.add(Calendar.MINUTE, 10);
			Calendar cal9 = new GregorianCalendar();
			cal9.set(2012, Calendar.MAY, 30);
			Calendar cal10 = new GregorianCalendar();
			cal10.set(2012, Calendar.JUNE, 10);

			Project project1 = new Project("Project 1", 20, true,
					"This Project one description").save();

			Event sprint1 = new Event("Project 1 sprint",
					"sprint 1 description.....", "C7.301", cal1, cal5);
			sprint1.project = project1;
			sprint1.type = et2;
			sprint1.status = true;
			sprint1.save();

			new EffortUnitProject(true, points, project1).save();

			Role projectAdminP1 = new Role("Project Admin", false).save();
			Role developerP1 = new Role("Developer", false).save();
			Role scrumMasterP1 = new Role("Scrum Master", false).save();
			Role projectMemberP1 = new Role("Project Member", false).save();
			Role productOwnerP1 = new Role("Product Owner", false).save();

			projectAdminP1.actions.addAll(projectAdmin.actions);
			projectAdminP1.save();
			developerP1.actions.addAll(developer.actions);
			developerP1.save();
			scrumMasterP1.actions.addAll(scrumMaster.actions);
			scrumMasterP1.save();
			projectMemberP1.actions.addAll(projectMember.actions);
			projectMemberP1.save();
			productOwnerP1.actions.addAll(productOwner.actions);
			productOwnerP1.save();

			new UserRoleProject(true, nemo, projectAdminP1, project1).save();
			new UserRoleProject(true, developerP1, project1).save();
			new UserRoleProject(true, scrumMasterP1, project1).save();
			new UserRoleProject(true, productOwnerP1, project1).save();
			new UserRoleProject(true, projectMemberP1, project1).save();

			Project project2 = new Project("Project 2", 20, true,
					"This is project 2 description").save();

			Event sprint2 = new Event("Project 2 sprint",
					"sprint 2 description.....", "C7.302", cal1, cal5);
			sprint2.project = project2;
			sprint2.type = et2;
			sprint2.status = true;
			sprint2.save();

			new EffortUnitProject(true, points, project2).save();

			Role projectAdminP2 = new Role("Project Admin", false).save();
			Role developerP2 = new Role("Developer", false).save();
			Role scrumMasterP2 = new Role("Scrum Master", false).save();
			Role projectMemberP2 = new Role("Project Member", false).save();
			Role productOwnerP2 = new Role("Product Owner", false).save();

			projectAdminP2.actions.addAll(projectAdmin.actions);
			projectAdminP2.save();
			developerP2.actions.addAll(developer.actions);
			developerP2.save();
			scrumMasterP2.actions.addAll(scrumMaster.actions);
			scrumMasterP2.save();
			projectMemberP2.actions.addAll(projectMember.actions);
			projectMemberP2.save();
			productOwnerP2.actions.addAll(productOwner.actions);
			productOwnerP2.save();

			new UserRoleProject(true, nemo, projectAdminP2, project2).save();
			new UserRoleProject(true, developerP2, project2).save();
			new UserRoleProject(true, scrumMasterP2, project2).save();
			new UserRoleProject(true, productOwnerP2, project2).save();
			new UserRoleProject(true, projectMemberP2, project2).save();

			Project project3 = new Project("Project 3", 20, true,
					"This is project 3 description").save();

			Event sprint3 = new Event("Project 3 sprint",
					"sprint 3 description.....", "C7.303", cal1, cal5);
			sprint3.project = project3;
			sprint3.type = et2;
			sprint3.status = true;
			sprint3.save();

			new EffortUnitProject(true, points, project3).save();

			Role projectAdminP3 = new Role("Project Admin", false).save();
			Role developerP3 = new Role("Developer", false).save();
			Role scrumMasterP3 = new Role("Scrum Master", false).save();
			Role projectMemberP3 = new Role("Project Member", false).save();
			Role productOwnerP3 = new Role("Product Owner", false).save();

			projectAdminP3.actions.addAll(projectAdmin.actions);
			projectAdminP3.save();
			developerP3.actions.addAll(developer.actions);
			developerP3.save();
			scrumMasterP3.actions.addAll(scrumMaster.actions);
			scrumMasterP3.save();
			projectMemberP3.actions.addAll(projectMember.actions);
			projectMemberP3.save();
			productOwnerP3.actions.addAll(productOwner.actions);
			productOwnerP3.save();

			new UserRoleProject(true, nemo, projectAdminP3, project3).save();
			new UserRoleProject(true, developerP3, project3).save();
			new UserRoleProject(true, scrumMasterP3, project3).save();
			new UserRoleProject(true, productOwnerP3, project3).save();
			new UserRoleProject(true, projectMemberP3, project3).save();

			Project GUCMafia = new Project(
					"GUCMafia",
					20,
					true,
					"This is a joint venture between the GUC and the mafia aiming to kill the life out of GUCians")
					.save();

			Event sprintGUC = new Event("GUC Mafia sprint",
					"GUC Mafia sprint description.....", "C7.301", cal1, cal5);
			sprintGUC.project = GUCMafia;
			sprintGUC.type = et2;
			sprintGUC.status = true;
			sprintGUC.save();

			Role projectAdminGUC = new Role("Project Admin", false).save();
			Role developerGUC = new Role("Developer", false).save();
			Role scrumMasterGUC = new Role("Scrum Master", false).save();
			Role projectMemberGUC = new Role("Project Member", false).save();
			Role productOwnerGUC = new Role("Product Owner", false).save();

			projectAdminGUC.actions.addAll(projectAdmin.actions);
			projectAdminGUC.save();
			developerGUC.actions.addAll(developer.actions);
			developerGUC.save();
			scrumMasterGUC.actions.addAll(scrumMaster.actions);
			scrumMasterGUC.save();
			projectMemberGUC.actions.addAll(projectMember.actions);
			projectMemberGUC.save();
			productOwnerGUC.actions.addAll(productOwner.actions);
			productOwnerGUC.save();

			new EffortUnitProject(true, hours, GUCMafia).save();

			ApplicationRole role3 = new ApplicationRole("Project Admin",
					GUCMafia).save();
			ApplicationRole role4 = new ApplicationRole("Big Boss", GUCMafia)
					.save();

			Task task3 = new Task("Task 3", "This is task 3", "High", t2, st1,
					null, rana).save();

			task3.save();
			new TaskUserUser(rawan, task3).save();
			Component defaultComp = new Component("Default component",
					"Serves as default component for that project", GUCMafia);
			defaultComp.save();

			Event defEvent1 = new Event("default", et4).save();
			defEvent1.project = GUCMafia;
			defEvent1.status = true;
			defEvent1.save();
			Event event4 = new Event(
					"Memorial Service",
					"This is a memorial service to honour all those who could not make it out of the GUC alive",
					"GUC", cal9, cal10);
			event4.project = GUCMafia;
			event4.tasks.add(task3);
			event4.status = true;
			event4.type = et1;
			event4.save();

			Component comp1 = new Component("C1", "User Stories", GUCMafia)
					.save();
			Component comp2 = new Component("C2", "Ay 7aga", GUCMafia).save();

			List<Component> components = new LinkedList<Component>();
			components.add(comp1);
			components.add(comp2);

			UserStory story1 = new UserStory(
					"I should be able to create new tasks", 10, "High", comp1,
					rana, null, components).save();

			story1.appRoles.add(role3);
			story1.appRoles.add(role4);
			story1.status = "NEW";
			story1.save();

			// new UserRoleProject(true, salem, developer, GUCMafia).save();
			new UserRoleProject(true, rawan, scrumMasterGUC, GUCMafia).save();
			new UserRoleProject(true, rana, projectAdminGUC, GUCMafia).save();
			new UserRoleProject(true, projMember, developerGUC, GUCMafia)
					.save();
			new UserRoleProject(true, fatma, productOwnerGUC, GUCMafia).save();
			new UserRoleProject(true, projectMemberGUC, GUCMafia).save();

			new ComponentUser(true, rana, comp1).save();

			Project se = new Project(
					"SE",
					10,
					true,
					"The aim of this project is to deprive CS students from sleeping and "
							+ " and cause them mental tortue. But ofcourse coolsoft is the best :D")
					.save();

			Role projectAdminSE = new Role("Project Admin", false).save();
			Role developerSE = new Role("Developer", false).save();
			Role scrumMasterSE = new Role("Scrum Master", false).save();
			Role projectMemberSE = new Role("Project Member", false).save();
			Role productOwnerSE = new Role("Product Owner", false).save();

			developerSE.actions.addAll(developer.actions);
			developerSE.save();
			scrumMasterSE.actions.addAll(scrumMaster.actions);
			scrumMasterSE.save();
			projectMemberSE.actions.addAll(projectMember.actions);
			projectMemberSE.save();
			productOwnerSE.actions.addAll(productOwner.actions);
			productOwnerSE.save();
			projectAdminSE.actions.addAll(projectAdmin.actions);
			projectAdminSE.save();

			new EffortUnitProject(true, hours, se).save();

			se.taskTypes.add(t4);
			se.save();

			Note n1 = new Note("Note 1", "I liked this sprint");
			n1.user = rana;
			n1.save();
			Note n2 = new Note("Note 2", "Good job everyone");
			n2.user = ramy;
			n2.save();
			Note n3 = new Note("Note 3", "This is a review note");
			n3.user = projMember;
			n3.save();

			Component defaultComp2 = new Component("Default component",
					"Serves as default component for that project", se);
			defaultComp2.save();
			ApplicationRole role1 = new ApplicationRole("Developer", se).save();
			ApplicationRole role2 = new ApplicationRole("Scrum Monster", se)
					.save();

			Component comp4 = new Component("C3", "UI", se).save();
			Component comp3 = new Component("C4", "Artifacts", se).save();

			new ComponentUser(true, rana, comp3).save();
			new ComponentUser(true, rawan, comp3).save();
			new ComponentUser(true, hafiza, comp3).save();

			LinkedList<Component> seComponents = new LinkedList<Component>();
			seComponents.add(comp4);
			UserStory story2 = new UserStory(
					"I should be able to assign myself to a task", 10, "High",
					comp3, rana, null, seComponents).save();
			UserStory story4 = new UserStory(
					"I should be able to able to draw a UML sequence diagram",
					10, "High", comp3, rana, null, null).save();
			UserStory story3 = new UserStory(
					"I should be able to review a task", 10, "High", comp4,
					rawan, null, null).save();
			UserStory story5 = new UserStory(
					"I should be able to create a user story", 10, "Low",
					comp4, rawan, null, null).save();
			UserStory story6 = new UserStory(
					"I should be able to be able to sleep at night", 10,
					"High", comp3, rawan, null, null).save();
			UserStory story7 = new UserStory(
					"I should be able to create a meeting", 10, "Medium",
					comp3, rawan, null, null).save();
			UserStory story8 = new UserStory(
					"I should be able to get some rest", 10, "High", comp4,
					rawan, null, null).save();
			UserStory story9 = new UserStory(
					"I should be able to view the burndown chart", 10, "Low",
					comp4, rawan, null, null).save();

			story3.appRoles.add(role1);
			story3.appRoles.add(role2);
			story3.save();
			story2.appRoles.add(role1);
			story2.status = "IN PROGRESS";
			story2.save();
			story4.appRoles.add(role1);
			story4.save();
			story5.appRoles.add(role1);
			story5.save();
			story6.appRoles.add(role1);
			story6.appRoles.add(role2);
			story6.save();
			story7.appRoles.add(role2);
			story7.save();
			story8.appRoles.add(role2);
			story8.save();
			story9.appRoles.add(role2);
			story9.save();

			DemoEntry demoEntry1 = new DemoEntry("correct steps 1,2,3", true,
					story2).save();
			DemoEntry demoEntry2 = new DemoEntry("wrong steps 1,2,3", false,
					story2).save();

			story2.demos.add(demoEntry1);
			story2.demos.add(demoEntry2);

			story2.save();

			new UserRoleProject(true, rana, developerSE, se).save();
			new UserRoleProject(true, rawan, developerSE, se).save();
			new UserRoleProject(true, hafiza, developerSE, se).save();
			new UserRoleProject(true, nemo, projectAdminSE, se).save();
			new UserRoleProject(true, ramy, scrumMasterSE, se).save();
			new UserRoleProject(true, projMember, projectMemberSE, se).save();
			new UserRoleProject(true, fatma, productOwnerSE, se).save();

			Task task1 = new Task();
			task1.description = "Task 1";
			task1.details = "This is task 1";
			task1.initialEffortEstimation = 17;
			task1.type = t3;
			task1.status = st3;
			task1.priority = "Medium";
			task1.creator = rawan;
			task1.userStory = story2;
			task1.save();
			TaskUser tu = new TaskUser(rana, task1);
			tu.status = true;
			tu.save();
			Task task2 = new Task();
			task2.description = "Task 2";
			task2.details = "This is task 2";
			task2.initialEffortEstimation = 20;
			task2.type = t2;
			task2.status = st2;
			task2.creator = rana;
			task2.userStory = story2;
			task2.priority = "Low";
			task2.save();

			new TaskUser(rawan, task2).save();

			Task task4 = new Task("Task 4", "This is task 4", "High", t1, st1,
					null, rana).save();
			task4.initialEffortEstimation = 5.0;
			task4.save();
			Task task5 = new Task("Task 5", "This is task 5", "High", t2, st4,
					null, rana).save();
			task5.initialEffortEstimation = 3.0;
			task5.save();
			Task task6 = new Task("Task 6", "This is task 6", "High", t1, st1,
					null, rana).save();
			task6.initialEffortEstimation = 8;
			task6.userStory = story6;
			task6.save();
			Task task7 = new Task("Task 7", "This is task 7", "High", t1, st1,
					null, rana).save();
			task7.userStory = story7;
			task7.initialEffortEstimation = 13;
			task7.save();
			Task task8 = new Task("Task 8", "This is task 8", "High", t1, st1,
					null, rana).save();
			task8.initialEffortEstimation = 13;
			task8.userStory = story8;
			task8.save();
			Task task9 = new Task("Task 9", "This is task 9", "High", t1, st1,
					null, rana).save();
			task9.initialEffortEstimation = 13;
			task9.save();
			Task task10 = new Task("Task 10", "This is task 10", "High", t1,
					st1, null, rana).save();
			task10.save();
			Task task11 = new Task("Task 11", "This is task 11", "High", t1,
					st1, null, rana).save();
			task11.save();
			Task task12 = new Task("Task 12", "This is task 12", "High", t1,
					st1, null, rana).save();
			task12.save();
			Task task13 = new Task("Task 13", "This is task 13", "High", t1,
					st1, null, rana).save();
			task13.save();

			new TaskUserUser(rawan, task1).save();
			new TaskUserUser(hafiza, task2).save();
			new TaskUserUser(rana, task3).save();
			new TaskUserUser(rawan, task4).save();
			new TaskUserUser(rana, task5).save();
			new TaskUserUser(rawan, task6).save();
			new TaskUserUser(rana, task7).save();
			new TaskUserUser(rawan, task8).save();

			new Log((Long) rana.getEntityId(), (Long) task5.getEntityId(),
					"Task", "changed the task type to impediment", (Long) se
							.getEntityId(), "Task is impossible").save();

			new Log((Long) rana.getEntityId(), (Long) task2.getEntityId(),
					"Task", "changed the task type to impediment", (Long) se
							.getEntityId(), "Can not be done in this sprint.")
					.save();

			Event defEvent2 = new Event("default", et4).save();
			defEvent2.project = se;
			defEvent2.tasks.add(task1);
			defEvent2.tasks.add(task2);
			defEvent2.tasks.add(task6);
			defEvent2.tasks.add(task7);
			defEvent2.tasks.add(task8);
			defEvent2.tasks.add(task9);
			defEvent2.tasks.add(task10);
			defEvent2.tasks.add(task11);
			defEvent2.tasks.add(task12);
			defEvent2.tasks.add(task13);

			defEvent2.save();
			Event event1 = new Event("CoolSoft sprint", "sprint 1", "C7.301",
					cal1, cal5);
			event1.project = se;
			event1.type = et2;
			event1.status = true;
			event1.userStories.add(story2);
			event1.userStories.add(story6);
			event1.userStories.add(story7);
			event1.userStories.add(story8);
			event1.tasks.add(task5);
			event1.tasks.add(task4);
			event1.save();
			Event event2 = new Event(
					"Closing Ceremony",
					"This is time where the CEO will handle out medals inshala to coolsoft for their outstanding performance :D",
					"GUC", cal5, cal6);
			event2.project = se;
			event2.tasks.add(task4);
			event2.status = true;
			event2.type = et1;
			event2.save();

			EventUser eu = new EventUser(rana, event2);
			eu.attendance = false;
			eu.save();

			Event event3 = new Event("GRADUATION!",
					"Computer Science class of 2012 actual graduation", "GUC",
					cal7, cal8);
			event3.project = se;
			event3.status = true;
			// event3.users.add(ran1);
			event3.type = et1;
			event3.sprint = event1;
			event3.save();

			EventUser eu2 = new EventUser(rana, event3);
			eu2.attendance = false;
			eu2.save();
			EventUser eu0 = new EventUser(rawan, event3).save();
			EventUser eu09 = new EventUser(hafiza, event3).save();
			eu09.attendance = true;
			eu09.save();

			Event event5 = new Event("Sprint Planning",
					"Should be held before the beginining of the next sprint",
					"GUC", cal5, cal6);
			event5.project = se;
			event5.tasks.add(task4);
			// .users.add(rana);
			event5.status = false;
			event5.type = et1;
			event5.sprint = event1;
			event5.save();

			EventUser eu3 = new EventUser(rana, event5);
			eu3.attendance = false;
			eu3.save();
			Event event6 = new Event(
					"Sprint Review ",
					"Review the work that has been completed and not completed",
					"GUC", cal5, cal6);
			event6.project = se;
			event6.tasks.add(task4);
			// event6.users.add(rana);
			event6.status = true;
			event6.sprint = event1;
			event6.type = et5;
			event6.notes.add(n1);
			event6.notes.add(n2);
			event6.notes.add(n3);
			event6.save();
			se.events.add(event6);
			se.save();
			event6.save();

			EventUser eu4 = new EventUser(rana, event6);
			eu4.attendance = false;
			eu4.save();

			/*
			 * Day day1 = new Day(); day1.date = cal3; day1.save(); Day day2 =
			 * new Day(); day2.date = cal4; day2.save();
			 * 
			 * new DayTask(5, task2, day1).save(); new DayTask(9, task2,
			 * day2).save(); new DayTask(9, task1, day2).save();
			 */

		}
	}
}